<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>

		<link href="../../js/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
		<link rel="stylesheet" type="text/css" href="footer.css" />
		<link rel="stylesheet" href="../../css/lystyle.css" />
		<link rel="stylesheet" href="../../css/backstage.css" />
		<link rel="stylesheet" href="../../css/zyUpload.css" type="text/css">
		<link rel="stylesheet" href="../../css/reset.css" />
		<script src="../../js/flexible.min.js" type="text/javascript" charset="utf-8"></script>

		<style type="text/css">
			/*修改底部字体颜色*/
			
			.foot:nth-child(2) {
				color: #e83023;
			}
			
			.ly-form-label {
				text-align: left;
				padding-left: 0.3266rem;
			}
			
			.col-xs-3 {
				width: 30%;
			}
			
			.col-xs-9 {
				width: 66%;
			}
		</style>

	</head>

	<body class="ly-bgcolor">
		<div id="wrap">
			<div id="main">
				<div id="header">
					<a id="headImg" href="javascript:history.go(-1)"><img class="headImg" src="../../images/12.png" /></a>
					<p id="headTitle">商家在线申请</p>
				</div>
				<div id="content" style="padding-bottom: 1.319444rem;">
					<div class="ly-form" style="">
						<div class="ly-form-item" style="padding: 0rem 0.33rem; ">
							<div class="row ly-item-content">
								<label class="control-label ly-form-label" style="width: 36%; float: left; font-size: 14px;">*商家名称：</label>
								<div  style=" float: left; width: 60%;">
									<input id="name" class="form-control ly-input" placeholder="请输入商家名称" />
								</div>
							</div>
						</div>
						<div class="ly-form-item">
							<div class="row ly-item-content">
								<label class="control-label ly-form-label"  style="width: 36%; float: left; font-size: 14px;">*所属行业：</label>
								<div style=" float: left;">
									<select id="industry" class="form-control ly_select">
										<option>移动</option>
										<option>服务</option>
									</select>
								</div>
							</div>
						</div>
						<div class="ly-form-item">
							<div class="row ly-item-content">
								<label class="control-label ly-form-label"  style="width: 36%; float: left; font-size: 14px;">*所属类别：</label>
								<div style=" float: left;">
									<select id="clas" class="form-control ly_select">
										<option>移动</option>
										<option>服务</option>
									</select>
								</div>
							</div>
						</div>
						<div class="ly-form-item">
							<div class="row ly-item-content">
								<label class="control-label ly-form-label"  style="width: 36%; float: left; font-size: 14px;">*联系人：</label>
								<div style=" float: left; width: 60%;"><input id="person" class="form-control ly-input" placeholder="请输入联系人姓名" /></div>
							</div>
						</div>
						<div class="ly-form-item">
							<div class="row ly-item-content">
								<label class="control-label ly-form-label" style="width: 36%; float: left; font-size: 14px;">*联系人电话：</label>
								<div style=" float: left; width: 60%;"><input id="phone" class="form-control ly-input" placeholder="请输入手机号" /></div>
							</div>
						</div>
						<div class="ly-form-item">
							<div class="row ly-item-content">
								<label class="control-label ly-form-label" style="width: 36%; float: left; font-size: 14px;">*商家详细地址：</label>
								<div style=" float: left; width: 60%;"><input id="add" class="form-control ly-input" placeholder="请输入详细地址" /></div>
							</div>
						</div>
						<div class="ly-form-item">
							<div class="row ly-item-content">
								<label class="control-label ly-form-label" style="width: 36%; float: left; font-size: 14px; ">备注：</label>
								<div style=" float: left; width: 60%; border: 1px solid #ccc;"><textarea id="remark" class="form-control ly-input" placeholder=""></textarea></div>
							</div>
						</div>
						<div>
							<a id="submit" style="display: block;color: #fff;padding: 0.25rem; " class="ly-borderp">提交</a>

						</div>
					</div>
				</div>
			</div>
		</div>
	</body>
	<script src="../../js/jquery-2.2.3.min.js"></script>
	<script src="../../js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../../common/js/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
	<!-- 引用核心层插件 -->
	<script src="../../js/addpicture/zyFile.js"></script>
	<!-- 引用控制层插件 -->
	<script src="../../js/addpicture/zyUpload.js"></script>
	<!-- 引用初始化JS -->
	<script src="../../js/addpicture/lanrenzhijia.js"></script>
	<script type="text/javascript">
		var tokenReztApp = $.cookie("tokenReztApp");
		if(!tokenReztApp) {
			window.location.href = "../login/login/login.html";
		}
		$(function() {
			currentyf();
		});

		//用户信息
		var user, role, goodsId;
		//获取当前会员信息
		function currentyf() {
			$.ajax({
				cache: false,
				type: "GET",
				url: "http://47.104.13.109/member-service/auth/current?token=" + tokenReztApp,
				dataType: "JSON",
				async: false,
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					$.removeCookie('tokenReztApp', {
						expires: 7,
						path: '/'
					});
					$.removeCookie("tokenRh", {
						expires: 7,
						path: '/'
					});
					$.removeCookie('memberId', {
						expires: 7,
						path: '/'
					});
					$.removeCookie('roleId', {
						expires: 7,
						path: '/'
					});
					window.location.href = "../login/login/login.html";
				},
				success: function(data) {
				/*	var check = false;
					for(var i = 0; i < data.roleList.length; i++) {
						var role = data.roleList[i].id;
						var deadline = new Date(data.roleList[i].deadline);
						if(role == "f1" && deadline >= new Date()) {
							check = true;
						}
						if(role == "f2" && deadline >= new Date()) {
							check = true;
						}
					}
					if(!check) {
						window.location.href = "../login/login/login.html";
					}*/
					user = data.loginName;
					role = data.roleList[0].id; //角色
					goodsId = data.id;

				}
			});
		}
		
		$(document).ready(function() {

			$("#submit").click(function() {
				if($("#name").val() == '' || $("#industry").val() == '' || $("#clas").val() == '' || $("#person").val() == '' || $("#person").val() == '' || $("#add").val() == '' || $("#phone").val() == '') {
					return alert("请将信息填写完整")
				}
				var pattern1 = /^1\d{10}$/;
				if(!pattern1.test($("#phone").val())) {
					return alert("请输入正确的手机号码");
				}
				$.ajax({
					type: "get",
					url: 'http://47.104.13.109/member-service/member/mine/member?token=' + $.cookie('tokenRh'),
					async: true,
					success: function(res) {
						var id = res.id;
						$.ajax({
							type: "post",
							url: "http://47.104.13.109/intention-service/tfIntentionBus",
							async: true,
							data: {
								name: $("#name").val(),
								industry: $("#industry").val(),
								clas: $("#clas").val(),
								person: $("#person").val(),
								phone: $("#phone").val(),
								add: $("#add").val(),
								remark: $("#remark").val(),
								memberId: id,
							},
							success: function(data) {
								if(data) {
									alert("提交成功请等待状态提示");
									history.back()
								}
							}
						});

					},
					error: function(res) {
						console.log(res);
					}
				});

			})

		})
	</script>

</html>